package com.huipinche.dao.impl;


import com.huipinche.dao.UserDao;
import com.huipinche.dao.bean.User;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: YunHai
 * @Date: 2021/8/4 10:50
 * @Description:
 */


public class UserDaoimpl implements UserDao{
  public   static List<User>userDate;
  public   static int id = 0;
  static {
        userDate = new ArrayList<>();
    }

    @Override
    public User getUserByName(String username) {
//        System.out.println(userDate);
        for(int i=0;i<userDate.size();i++ ){
//            System.out.println(userDate.get(i).getUser());
//            System.out.println(username);
//            System.out.println(userDate.get(i).getUser().equals(username));
            if(userDate.get(i).getUser().equals(username)){
         //       System.out.println("持久层有东西进来");
                return userDate.get(i);
            }

        }

         return null;
    }

    @Override
    public int insertUser(User user) {
        id ++;
        user.setId(id);
        userDate.add(user);
//        System.out.println("我被写入用户了");
//        System.out.println(user.toString());
        return 1;
    }
}
